/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年9月14日
 */
package com.massyframework.beanskin.license.signature.wizard;

import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Objects;

/**
 * 证书记录
 * @author huangkh
 *
 */
public class CertificateEntry {
	
	private KeyStore keyStore;
	private String alias;
	private PrivateKey key;
	private X509Certificate x509Cert;
	
	/**
	 * 构造方法
	 */
	public CertificateEntry(KeyStore keyStore, String alias, X509Certificate x509Cert) {
		this.keyStore = Objects.requireNonNull(keyStore, "\"keystore\" cannot ben null.");
		this.alias = Objects.requireNonNull(alias, "\"alias\" cannot be null.");
		this.x509Cert = Objects.requireNonNull(x509Cert, "\"x509Cert\" cannot be null.");
	}

	/**
	 * 键存储
	 * @return {@link KeyStore}
	 */
	public KeyStore getKeyStore() {
		return this.keyStore;
	}

	/**
	 * 别名
	 * @return the alias
	 */
	public String getAlias() {
		return alias;
	}


	/**
	 * 签名算法
	 * @return the sigAlgName
	 */
	public String getSigAlgName() {
		return this.x509Cert.getSigAlgName();
	}


	/**
	 * 签发人
	 * @return the issuerDN
	 */
	public String getIssuerDN() {
		return this.x509Cert.getIssuerDN().getName();
	}

	/**
	 * x509证书
	 * @return {@link X509Certificate}
	 */
	public X509Certificate getX509Certificate() {
		return this.x509Cert;
	}

	/**
	 * 密钥
	 * @return the key
	 */
	public PrivateKey getKey() {
		return key;
	}
	
	public void setKey(PrivateKey key) {
		this.key = key;
	}
}
